/**  
* @Title: IndexController.java
* @Package com.house.service.controller
* @version V1.0  
*/ 
package com.hjb.service.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.domain.Member;
import com.hjb.service.user.UserService;

/**
* @ClassName: IndexController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>
* @date 2017年4月28日 下午6:34:52
*/
@Controller
public class IndexController {

	@Autowired
	private UserService userService;
	
	/**
	 * 初始化首页
	* @Title: index
	* @Description: TODO(跳转首页)
	* @param     设定文件
	* @return void    返回类型
	* @throws
	 */
	@LogInfo(logType = LogType.查询, operationContent = "进入首页")
	@RequestMapping(value="/")
	public String index(HttpServletRequest request){
		
		return "home/home";
		
	}
	
	
	@LogInfo(logType = LogType.回调, operationContent = "分享回调")
	@RequestMapping(value="/share")
	public void share(HttpServletRequest request,HttpServletResponse response){
		
		String shareType = request.getParameter("shareType");
		
		String inviteCode= request.getParameter("inviteCode");
		
		request.getSession().setAttribute("parentId", inviteCode);
		
		request.getSession().setAttribute("inviteCode", request.getParameter("inviteCode"));
		
		String zfurl = request.getParameter("zfurl");
		
		if(zfurl!=null&&!zfurl.equals("")){
			try {
				response.sendRedirect(zfurl);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}else{
			
			if(shareType != null && shareType.equals("1")){
				
				try {
					response.sendRedirect("/theme/home/houseDetails.html?houseId="+request.getParameter("houseId"));
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}else{
				
				try {
					response.sendRedirect("/theme/home/home.html");
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			
		}
		
		
		
//		return "home/home";
		
	}

	
}
